home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / Documentation / Development Notes / Compiling IDL Files < prev    next >
Encoding:
Text File  |  1996-09-19  |  6.2 KB  |  108 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                     
  5. Compiling IDL Files 
  6. ODF Release 2                                                                                                                                                            
  7.  
  8. This document provides information about compiling IDL files.
  9.  
  10.  
  11. Table of Contents
  12. -------------------------
  13. • Installing ToolServer and SOM
  14. • Compiling IDL Files (CodeWarrior IDE)
  15. • Compiling IDL Files (MPW)
  16.     • Compiling
  17.     • Common Problems
  18.  
  19. IMPORTANT: this document assumes you have already followed the MPW and/or CodeWarrior Installation Guide.
  20.  
  21.  
  22.  
  23. Installing ToolServer and SOM
  24.  
  25. To compile IDL files, you need to use the SOM compiler. SOM currently only runs as an MPW or ToolServer tool and is part of the ETO #21 package. If you are using CodeWarrior then you should install ToolServer. ToolServer is available from ETO, MPW Pro and CodeWarrior Gold Reference.
  26.  
  27. CodeWarrior users should also have installed the “SOMobjects™ TS” plugin tool. This tool is located in the “Getting Started:CodeWarrior Development:CodeWarrior Additions:INTO CodeWarrior Plugins” folder, and needs to be placed in the “CodeWarrior Plugins : Compilers” folder in your CodeWarrior folder. If you followed the “Installation Guide” procedure for CodeWarrior this tool should already be installed.
  28.  
  29.  
  30.  
  31. Compiling IDL Files (CodeWarrior)
  32.  
  33. Once you’ve written an IDL file, add it to the CodeWarrior project. Compile it directly by selecting the file and pressing command-K or by selecting the file and choosing Compile from the Project menu. If the file compiles without errors, the SOM compiler will have generated three new files, ending with the extensions .xih, .xh, and .cpp. Add the .cpp file to your project. This is where you must implement your code.
  34.  
  35. If you ever need to change your .idl file, the SOM compiler is smart enough to modify your .cpp file in place. You don't have to worry about your code being deleted. In some cases it will create a new set of methods (for instance, if you rename your SOM class); other times it fixes prototypes for you, and even inserts comments telling you what it did. Sounds scary, but it works fine.
  36.  
  37. You may notice that you don't have to use ToolServer directly. The SOM plugin tool looks like a standard compiler to CodeWarrior, but in reality it sends AppleEvents to ToolServer to compile the .idl file. As far as CodeWarrior is concerned, the plugin tool is doing the compile. Eventually we plan to make the SOM compiler a true plugin, eliminating the need for ToolServer. However, since ToolServer is doing the compile and not CodeWarrior, it can’t read open windows which haven’t been saved to disk. Make sure to save your .idl file to disk before compiling it.
  38.  
  39. At the moment, the SOM plugin tool is not officially supported or tested. It seems to work for most people. If you have problems then you may need to remove the .idl file from the project window and use the Non-CodeWarrior approach below.
  40.  
  41.  
  42.  
  43. Compiling IDL Files (MPW)
  44.  
  45.  
  46. Compiling IDL files requires that you use MPW and SOM. Both of these are available on ETO #21 and other development CDs.
  47.  
  48.  
  49. Compiling
  50.  
  51. • Add your .idl file to the MacMake.bmk file (the "Makefile")
  52. When you generated your part with PartMaker, it created the CodeWarrior project and an MPW makefile, called MacMake.bmk. The makefile lists all the output of the idl files, like so:
  53.  
  54. __ComponentSourcesFromIDL = ∂
  55.         "{_FWTargetDir}SOMPart.cpp" ∂
  56.         "{_FWTargetDir}SOMPart.xh"  ∂
  57.         "{_FWTargetDir}SOMPart.xih"
  58.  
  59. __ComponentObjects = ∂
  60.         "{_FWObjDir}"SOMPart.cpp.o
  61.  
  62. You don't list the .idl file in the makefile, instead you list the output files. The Make tool will determine how to build those output files based on our default rules.
  63.  
  64. If your idl file was called MyInterface.idl, you will add the output files to those definitions like this:
  65.  
  66. __ComponentSourcesFromIDL = ∂
  67.         "{_FWTargetDir}MyInterface.cpp" ∂
  68.         "{_FWTargetDir}MyInterface.xih" ∂
  69.         "{_FWTargetDir}MyInterface.xh" ∂
  70.         "{_FWTargetDir}SOMPart.cpp" ∂
  71.         "{_FWTargetDir}SOMPart.xh"  ∂
  72.         "{_FWTargetDir}SOMPart.xih"
  73.  
  74. __ComponentObjects = ∂
  75.         "{_FWObjDir}"SOMPart.cpp.o
  76.  
  77. You also need to add dependency rules, like this:
  78.  
  79. "{_FWTargetDir}MyInterface.xih" ƒ "{_FWTargetDir}MyInterface.idl"
  80.  
  81. "{_FWTargetDir}MyInterface.xh" ƒ "{_FWTargetDir}MyInterface.idl"
  82.  
  83. "{_FWTargetDir}MyInterface.cpp" ƒ "{_FWTargetDir}MyInterface.idl" ∂
  84.         "{_FWTargetDir}MyInterface.xh" ∂
  85.         "{_FWTargetDir}MyInterface.xih"
  86.  
  87. • Run FWBuild
  88.  
  89. You are finally ready to build. In the MPW Worksheet, type this:
  90. (substitute MyPart with your part's folder's name)
  91. FWBuild -Metrowerks "{ODFDev}MyPart:Sources:MyPart.SOM"
  92.  
  93. You must have your part's folder in the same folder as ODF for this to work. This is required anyway because some ODF scripts have relative paths.
  94.  
  95. FWBuild will run somc to output your .cpp, .xh, and .xih files. At this point you can implement your extension. If you change your .idl file, you need to do this step over again (but only this step). When the SOM compiler writes your .cpp file it will not delete anything, so you don't need to worry about saving code. It rewrites, not replaces, the .cpp file. In some cases it will create a new set of methods (for instance, if you rename your SOM class); other times it fixes prototypes for you, and even inserts comments telling you what it did. Sounds scary, but it works fine. 
  96.  
  97.  
  98. Common Problems
  99.  
  100. You may get "include file not found" errors. This would mean that you are trying to #include other .idl files which are not found in the standard OpendDoc or ODF set. You will need to add the locations of those other .idl files to the makefile. For example, if you were building Cyberdog parts you would probably have to put the PublicIncludes folder in your CodeWarrior folder, and would need to change the include listing like this:
  101.  
  102. __IDLIncludeDirs = d
  103.         -I "HD:CodeWarrior:MacOS Support:Headers:PublicIncludes:" d
  104.         -I "{FWODIDLIncludes}"
  105.  
  106.  
  107. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  108. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.